<template>
  <div class="header">
    <!--顶部导航栏左边-->
    <div class="l-content">


      <el-button
          type="primary"
          plain
          icon="el-icon-menu"
          size="mini"

          @click="collapseMenu"
      >

      </el-button>
      <!-- 面包屑导航 start -->
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>

        <!--当期页面-->
        <el-breadcrumb-item :to="current.path" v-if="current">
          {{ current.label }}
        </el-breadcrumb-item>
      </el-breadcrumb>
      <!-- 面包屑导航 end -->
    </div>

    <!--顶部导航栏右边-->
    <div class="r-content">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img :src="userImg" alt class="userImg"/>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item @click.native="logout">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import {mapState} from "vuex";

export default {
  name: "",
  props: [""],
  data() {
    return {
      userImg: require("@/assets/images/user.png")
    };
  },
  components: {},
  computed: {
    ...mapState(
        {
          current: state => state.tab.currentMenu
        }
    )
  },
  methods: {
    // 点击后收缩
    collapseMenu() {
      this.$store.commit('collapseMenu')
    },

    // 点击后退出
    logout() {
      this.$store.commit('clearToken')
      this.$store.commit('clearMenu')
      location.reload();

    }
  }
};
</script>

<style lang="scss" scoped>
.header {
  display: flex;
  height: 100%;
  align-items: center;

  // 两边对称
  justify-content: space-between;
}

.l-content {
  display: flex;
  align-items: center;

  .el-button {
    margin-right: 20px;
  }
}

.r-content {
  .userImg {
    height: 40px;
    width: 40px;
    background-size: 100%;
    border-radius: 50%;
  }
}
</style>

<!--这部分不能用scoped-->
<style lang="scss">
.el-breadcrumb__item {
  .el-breadcrumb__inner {
    color: #666;
    font-weight: normal;
  }

  &:last-child {
    .el-breadcrumb__inner {
      color: #fff;
    }
  }
}
</style>